<?php

namespace App\Models;

use Dcat\Admin\Traits\HasDateTimeFormatter;

use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Storage;

class Banner extends Model
{
    use HasDateTimeFormatter;

    protected $appends = ['image_src'];
    public function school()
    {
        return $this->belongsTo(School::class);
    }

    public function imageSrc(): Attribute
    {
        return Attribute::make(get: fn() => $this->image ? Storage::disk('oss')->url($this->image) : null);
    }
}
